class CommId:
    """Communications id identifies a data request/frame from the Tx
    layer up to the neon application layer.

    Note: blank entries match everything (or represent information
    that is not needed).
    """
    ANY = ''
    
    def __init__(self,
                 tx_type = '', iface_id = '', channel_id = '', peer_id = ''):
        self.tx_type    = tx_type
        self.iface_id   = iface_id
        self.channel_id = channel_id
        self.peer_id    = peer_id

    def __str__(self):
        return '%s:%s:%s:%s' % (self.tx_type, self.iface_id,
                                self.channel_id, self.peer_id)
    
    @staticmethod
    def from_str(s):
        s = s.split(':', 3)
        return CommId(s[0], s[1], s[2], s[3])

def from_str(s):
    return CommId.from_str(s)
